Skip to content

Conversation

@thezz9
Copy link
Collaborator

@thezz9 thezz9 commented Jul 2, 2025

일단 임시방편으로 thread.sleep 6초 걸어뒀습니다.
이러니 init이 유실 안 되네요.. 더 나은 방법을 찾아야할 거 같습니다.

Summary by CodeRabbit

  • 신규 기능

    • 메시지 발행 시 각 단계(init, case, final)에 대한 정보성 로그가 추가되었습니다.
  • 버그 수정

    • 불필요한 공백 및 사용되지 않는 import 문이 제거되었습니다.
  • 기타

    • 메시지 처리 시 6초의 대기 시간이 추가되었습니다.

@thezz9 thezz9 self-assigned this Jul 2, 2025
@thezz9 thezz9 added the bug Something isn't working label Jul 2, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 2, 2025

Walkthrough

이 변경 사항들은 주로 불필요한 import 문을 제거하고, 로깅을 추가하며, 메시지 큐 소비자에서 비동기 제출 처리 전에 6초간 대기하는 로직을 도입했습니다. 기능적 로직 변경은 없으며, 코드의 가독성과 추적성을 개선하는 데 중점을 두었습니다.

Changes

파일(들) 변경 요약
.../submission/service/SubmissionService.java 불필요한 import 문 및 불필요한 빈 줄 제거
.../infrastructure/event/listener/RedisJudgeQueueConsumer.java 메시지 수신 후 비동기 제출 처리 전 6초 대기 로직 추가
.../infrastructure/event/publisher/StompMessageService.java 불필요한 import 제거, @slf4j 추가, 주요 메시지 발행 시 로깅 추가

Sequence Diagram(s)

sequenceDiagram
    participant RedisJudgeQueueConsumer
    participant SubmissionService

    RedisJudgeQueueConsumer->>RedisJudgeQueueConsumer: 메시지 수신 로그 출력
    RedisJudgeQueueConsumer->>RedisJudgeQueueConsumer: 6초 대기 (Thread.sleep)
    RedisJudgeQueueConsumer->>SubmissionService: processSubmissionAsync(msg) 호출
Loading

Suggested reviewers

  • NCookies
  • minjee2758
  • chat26666

Poem

🐇
코드를 깔끔하게, import를 쓱—
6초 기다려, 메시지엔 뜻!
로그를 남겨, 발행의 순간
토끼는 춤추네, 코드가 환한
오늘도 깔끔, 내일도 멋짐!
🥕

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/java/org/ezcode/codetest/infrastructure/event/publisher/StompMessageService.java (1)

65-65: 로그 메시지 개선 제안

현재 로그 메시지가 간단하여 디버깅 시 더 많은 정보가 필요할 수 있습니다.

다음과 같이 더 상세한 정보를 포함하는 것을 고려해보세요:

-        log.info("init 발행");
+        log.info("[STOMP] init 테스트케이스 발행 - sessionKey: {}, user: {}, count: {}", sessionKey, principalName, dataList.size());

-        log.info("case 발행");  
+        log.info("[STOMP] 테스트케이스 결과 발행 - sessionKey: {}, user: {}, result: {}", sessionKey, principalName, data.isCorrect());

-        log.info("final 발행");
+        log.info("[STOMP] 최종 결과 발행 - sessionKey: {}, user: {}, status: {}", sessionKey, principalName, data.getOverallStatus());

Also applies to: 78-78, 91-91

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 151fcd0 and c6c067e.

📒 Files selected for processing (3)
  • src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java (0 hunks)
  • src/main/java/org/ezcode/codetest/infrastructure/event/listener/RedisJudgeQueueConsumer.java (1 hunks)
  • src/main/java/org/ezcode/codetest/infrastructure/event/publisher/StompMessageService.java (4 hunks)
💤 Files with no reviewable changes (1)
  • src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:159-165
Timestamp: 2025-06-28T02:03:38.693Z
Learning: User thezz9's service (ezcode) targets Korean users exclusively ("찐 한국인밖에 안 옴"), so Korean language hardcoding in commit messages and UI elements is intentional and appropriate for their use case.
Learnt from: thezz9
PR: ezcode-my/backend#111
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:58-73
Timestamp: 2025-06-27T09:53:52.378Z
Learning: User thezz9 acknowledges technical issues when flagged but often indicates they will address them later ("나중에 바꿀 겨"), suggesting they prioritize getting core functionality working first before refining implementation details.
Learnt from: chat26666
PR: ezcode-my/backend#37
File: src/main/java/org/ezcode/codetest/infrastructure/elasticsearch/repository/ProblemElasticsearchRepositoryDsl.java:10-10
Timestamp: 2025-06-06T19:56:27.759Z
Learning: When user chat26666 mentions that code was implemented in a previous PR but explanation was missing, they may submit a follow-up PR just to add documentation/explanation without the actual implementation code.
Learnt from: thezz9
PR: ezcode-my/backend#30
File: src/main/java/org/ezcode/codetest/domain/problem/model/dto/SubmissionData.java:42-53
Timestamp: 2025-06-04T13:12:16.729Z
Learning: 사용자 thezz9는 개발 시 기능적 정확성을 먼저 달성한 후 세부 리팩터링을 나중에 하는 접근 방식을 선호한다. 테스트 단계에서는 하드코딩된 값도 허용한다.
Learnt from: thezz9
PR: ezcode-my/backend#75
File: src/main/java/org/ezcode/codetest/application/submission/aop/CodeReviewLockAspect.java:25-41
Timestamp: 2025-06-19T06:37:57.845Z
Learning: User thezz9 tends to skip validation for scenarios they consider unlikely to occur, but is willing to implement defensive programming practices when suggested for code robustness.
Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:93-96
Timestamp: 2025-06-28T02:04:24.957Z
Learning: User thezz9 sometimes temporarily uses less secure or inconsistent exception handling (like RuntimeException with raw error bodies) for debugging purposes when error messages are being hidden in the normal application flow, but acknowledges this as technical debt and fixes it once debugging is complete.
Learnt from: thezz9
PR: ezcode-my/backend#132
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubContentBuilder.java:72-72
Timestamp: 2025-07-02T09:39:31.475Z
Learning: User thezz9 prefers to proceed with breaking changes to path structures when it improves the organization, rather than maintaining backward compatibility or implementing migration strategies.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (1)
src/main/java/org/ezcode/codetest/infrastructure/event/publisher/StompMessageService.java (1)

17-19: 로깅 기능 추가 승인

디버깅과 모니터링을 위한 로깅 추가가 적절합니다.


try {
log.info("[컨슈머 수신] {}", msg.sessionKey());
Thread.sleep(6000);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

임시 해결책으로 Thread.sleep 사용 - 향후 개선 필요

타이밍 이슈 해결을 위한 임시 방편으로 이해되지만, 다음 사항들을 고려해 주세요:

  1. 성능 영향: 블로킹 방식으로 처리량 저하 가능성
  2. 리소스 낭비: 스레드 풀의 스레드가 6초간 대기 상태로 유지
  3. 불확실성: 6초가 항상 충분한 시간인지 보장되지 않음

향후 개선 방안:

  • CompletableFuture.delayedExecutor() 사용한 비동기 지연 처리
  • Redis pub/sub 기반의 이벤트 동기화
  • 초기화 완료 신호를 확인하는 polling 메커니즘
// 향후 개선 예시 (비동기 지연 처리)
CompletableFuture.delayedExecutor(6, TimeUnit.SECONDS)
    .execute(() -> submissionService.processSubmissionAsync(msg));

Thread.sleep(6000) 제거 및 비동기 지연 처리 도입 필요

현재 Redis 스트림 메시지 컨슈머에서 Thread.sleep(6000)을 사용한 고정 대기는 다음 문제를 유발할 수 있습니다:

  • 성능 저하: 스레드가 블로킹되어 처리량 감소
  • 리소스 낭비: 스레드 풀이 불필요하게 점유
  • 불확실성: 6초가 항상 적절한 지점 보장 불가

아래와 같은 비동기 지연 처리 방식으로 교체를 권장합니다:

// CompletableFuture.delayedExecutor() 사용 예시
CompletableFuture
    .delayedExecutor(6, TimeUnit.SECONDS)
    .execute(() -> submissionService.processSubmissionAsync(msg));

또는 Redis pub/sub 이벤트 기반 동기화, 초기화 완료 신호 확인용 폴링 메커니즘 등으로 개선해 주세요.

[src/main/java/org/ezcode/codetest/infrastructure/event/listener/RedisJudgeQueueConsumer.java:39]

🤖 Prompt for AI Agents
In
src/main/java/org/ezcode/codetest/infrastructure/event/listener/RedisJudgeQueueConsumer.java
at line 39, replace the blocking Thread.sleep(6000) call with a non-blocking
asynchronous delay using CompletableFuture.delayedExecutor to avoid thread
blocking and improve performance. Implement the delay by scheduling the
subsequent processing logic inside the delayedExecutor's execute method, or
alternatively use an event-driven or polling mechanism to handle synchronization
without fixed thread sleeps.

@thezz9 thezz9 merged commit 0734680 into dev Jul 2, 2025
2 checks passed
@thezz9 thezz9 deleted the fix/submission-sleep branch July 2, 2025 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants